package vn.vnvas.xoso.mienbac;

import vn.vnvas.xoso.R;
import vn.vnvas.xoso.mienbac.ketqua.tab_ketqua;
import vn.vnvas.xoso.mienbac.thongke.tab_thongke;
import vn.vnvas.xoso.mienbac.tuongthuat.tab_tuongthuat;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabContentFactory;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class KetQuaTheoTinh extends TabActivity {

	TabHost mTabHost;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab_host);

		mTabHost = (TabHost) findViewById(android.R.id.tabhost);
		//mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_deivder_white);

		Intent int1 = new Intent(this, tab_ketqua.class);
		Intent int2 = new Intent(this, tab_tuongthuat.class);
		Intent int3 = new Intent(this, tab_thongke.class);

		setupTab(new TextView(this), "Kết Quả", int1);
		setupTab(new TextView(this), "Tường Thuật",int2);
		setupTab(new TextView(this), "Thống kê",int3);

	}

	private void setupTab(final View view, final String tag,final Intent intent) {
		View tabview = createTabView(mTabHost.getContext(), tag);
		TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview)
				.setContent(new TabContentFactory() {
					public View createTabContent(String tag) {
						return view;
					}
				});

		setContent.setContent(intent);
		mTabHost.getTabWidget().setDividerDrawable(R.drawable.divider);
		mTabHost.addTab(setContent);
		
	}

	private static View createTabView(final Context context, final String text) {
		View view = LayoutInflater.from(context)
				.inflate(R.layout.tabs_bg, null);
		TextView tv = (TextView) view.findViewById(R.id.tabsText);
		tv.setText(text);

	//	ImageView icon = (ImageView) view.findViewById(R.id.tabsIcon);
	//	icon.setImageResource(iconResource);
		return view;

	}

}
